<template>
  <div class="hv-flex hv-flex-align-items-center">
    <a-input-number
      v-model:value="inputVal"
      :min="0"
      :max="360"
      :step="1"
      size="small"
      @change="valueChange"
    />
    <div
      class="hv-margin-left10 hv-cursor-pointer"
      title="旋转0度"
      @click="valueChange(0)"
    >
      <hv-dynamic-icon :iconName="'ArrowDownOutlined'" />
    </div>
    <div
      class="hv-margin-left10 hv-cursor-pointer"
      title="旋转180度"
      @click="valueChange(180)"
    >
      <hv-dynamic-icon :iconName="'ArrowUpOutlined'" />
    </div>
    <div
      class="hv-margin-left10 hv-cursor-pointer"
      title="旋转90度"
      @click="valueChange(90)"
    >
      <hv-dynamic-icon :iconName="'ArrowLeftOutlined'" />
    </div>
    <div
      class="hv-margin-left10 hv-cursor-pointer"
      title="旋转270度"
      @click="valueChange(270)"
    >
      <hv-dynamic-icon :iconName="'ArrowRightOutlined'" />
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref, watch } from "vue";

export default defineComponent({
  name: "TransformRotateInput",
  components: {},
  props: {
    value: {
      type: Number,
      default: 0,
    },
  },
  emits: ["update:value"],
  setup(props, { emit }) {
    const inputVal = ref<number>(0);

    const valueChange = (val: number) => {
      emit("update:value", val);
    };

    watch(
      () => props.value,
      () => {
        inputVal.value = props.value;
      },
      { deep: false, immediate: true }
    );

    return {
      inputVal,
      valueChange,
    };
  },
});
</script>

<style lang="less" scoped>
@import "./TransformRotateInput.less";
</style>
